﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace gamecontrol
{
    public partial class Brick : UserControl
    {
        private FrameworkElement rootElement;
        private bool hit;
        private Canvas boardRoot;

        public Brick(Canvas boardRoot)
        {
            InitializeComponent();
            this.boardRoot = boardRoot;
            boardRoot.Children.Add(this);
        }

        public void onHit()
        {
            if (hit)
            {
                // destroy the item
                boardRoot.Children.Remove(this);
            }
            else
            {
                // mark it as hit to destroy in the next turn
                hit = !hit;
                SolidColorBrush color = new SolidColorBrush();
                color.Color = hit ? Color.FromArgb(0xff, 0xC1, 0x25, 0x25) : Color.FromArgb(0xff, 0x25, 0x65, 0xC1);
                brickBody.Fill = color;
            }
        }
    }
}
